<?php
/**
 * Created by PhpStorm.
 * User: Mizuki
 * Date: 2019/7/10
 * Time: 10:41
 */
namespace Api\Model;

class UserModel extends BaseModel {
    public static $STATUS_IN_USE = 1;
    public static $STATUS_DELETED = 0;

    /*
     * 通过idUser获得用户信息
     */

    public function getInfoByUid($uid)
    {
        if(!$uid) {
            return ['success' => FALSE, 'message' => 'uid参数错误'];
        }
            $userInfo = $this -> where(['idUser' => $uid, 'status' => self::$STATUS_IN_USE])->find();
            return empty($userInfo) ? ['success' => FALSE, 'message' => '无数据'] : $userInfo;
    }

    /*
     * 通过openid获取用户信息
     */
    public function getInfoByOpenid($opneid) {
        if(!$opneid) {
            return ['success' => FALSE, 'message' => 'openid参数错误'];
        }
            $userInfo = $this -> where(['openid' => $opneid, 'status' => self::$STATUS_IN_USE])->find();
            return empty($userInfo) ? ['success' => FALSE, 'message' => '无数据'] : $userInfo;
    }
}